#ifndef SINGLETON_H
#define SINGLETON_H

template <class T>
class Singleton {
public:
	static T& instance() {
		if(!mInstance) {
			mInstance = createInstance();
		}
		return *mInstance;
	}
protected:
	static T* createInstance();
	Singleton() {}
private:
	Singleton(const Singleton& root);
	Singleton& operator=(const Singleton&);

	static T* mInstance;
};

#define	METHOD_OF_CREATE_SINGLETON_INSTATCE(TYPE) template<> TYPE* Singleton<TYPE>::createInstance()
#define INJECT_DEPENDENCY_TO_SINGLETONE(INTERFACE, INSTANCE_CREATE) METHOD_OF_CREATE_SINGLETON_INSTATCE(INTERFACE) { return INSTANCE_CREATE; }

#endif // SINGLETON_H
